import storage from 'good-storage'

export function getTimer () {
  let timer = Math.round(new Date().getTime() / 1000)
  let time = storage.get('verificationTime', 0)
  if (timer - time >= 60) {
    storage.remove('verificationTime')
    return 60
  } else {
    return Math.abs(timer - time - 60)
  }
}
export function setTimer () {
  let timer = Math.round(new Date().getTime() / 1000)
  storage.set('verificationTime', timer)
  console.log(storage.get('verificationTime'))
}

export function getTimer1 () {
  let timer = Math.round(new Date().getTime() / 1000)
  let time = storage.get('verificationTime1', 0)
  if (timer - time >= 60) {
    storage.remove('verificationTime1')
    return 60
  } else {
    return Math.abs(timer - time - 60)
  }
}
export function setTimer1 () {
  let timer = Math.round(new Date().getTime() / 1000)
  storage.set('verificationTime1', timer)
  console.log(storage.get('verificationTime1'))
}

// 存token
// export function setUserInfo (tk) {
//   storage.set('token', tk)
// }
// 取token
export function getUserInfo () {
  console.log(storage.get('token', ''))
  if (storage.get('token', '') === '') {
    return true
  }
}
// 存个人信息
export function setUser (msg) {
  storage.set('user', msg)
}
// // 取个人信息
// export function getUser (msg) {
//   storage.set('user', msg)
// }
